rm(list = ls())

library(kableExtra)
library(tidyverse)

## Load MP data

dat <- readRDS('data/mp_data.rds')  %>%
  filter(vote_abstain_no_show == 0) %>%
  filter(elecper != 8)

## 

summary_all <- dat %>%
  filter(!is.na(ags)) %>% 
  count(ags_name) %>%
  arrange(-n) %>%
  top_n(n = 9) %>%
  mutate(ags_name = str_remove_all(ags_name, ', Stadt|, Landeshauptstadt|, Freie und Hansestadt'))

breslau <- data.frame(ags_name = 'Breslau',
                      n = 16)

summary_all <- bind_rows(summary_all, breslau) %>%
  arrange(-n)

# To Tex Table 

tab_tex <- summary_all %>%
  kableExtra::kable(., 
                    format = 'latex', 
                    booktabs = T,
                    linesep = "",
                    col.names = c('City', 'Number of MPs born in city'),
                    label = 'cities_birth_count',
                    caption = 'Top 10 places of birth in MP sample',
                    digits = 2) %>%
  kable_styling(latex_options = c("HOLD_position"), 
                position = "center",
                full_width = F,
                font_size = 12) 

tab_tex




